package concurrent;

import org.junit.Test;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author: zhenzhong.wang@honeywell.com
 * @date: 2019/8/12 11:31 AM
 */
public class ProcessorTest {
  ThreadPoolExecutor executor = new ThreadPoolExecutor(
      Runtime.getRuntime().availableProcessors(),
      24,
      10,
      TimeUnit.SECONDS,
      new LinkedBlockingQueue<>(100)
  );

  @Test
  public void test1() {
    System.out.println("处理器数量：" + Runtime.getRuntime().availableProcessors());
    for (int i = 0; i < 100; i++) {
      int j = i;
      Runnable runnable = new Runnable() {
        @Override
        public void run() {
          System.out.println("test" + j);
        }
      };
      Thread thread = new Thread(runnable);
      thread.start();
    }
  }
}
